package net.kazed.nextaction.database;

import java.util.HashMap;
import java.util.Map;

/**
 * Type of Task.
 * @author Koert Zeilstra
 */
public enum TaskType {

    UNPROCESSED(0), NEXT_ACTION(1), WAITING(2), IDEA(3);
    
    private static final Map<Integer, TaskType> TYPES;
    
    static {
        TYPES = new HashMap<Integer, TaskType>();
        for (TaskType taskType : TaskType.values()) {
            TYPES.put(taskType.type, taskType);
        }
    }
    
    private int type = 0;
    
    /**
     * Constructor.
     * @param type Type ID.
     */
    TaskType(int type) {
        this.type = type;
    }
    
    /**
     * @return Type.
     */
    public int getType() {
        return type;
    }

    /**
     * @param type Type number.
     * @return TaskType of corresponding type.
     */
    public static TaskType getEnum(Integer type) {
        TaskType taskType = null;
        if (type != null) {
            taskType = TYPES.get(type);
        }
        return taskType;
    }
    
}
